package vue;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class PanelStats extends JPanel implements ActionListener{

	private JPanel panelButton;
	private JButton buttonJou, buttonGen;
	private FenetrePrincipale ihm;
	private JLabel labelStat;
	
	public PanelStats(FenetrePrincipale ihm) {
		this.ihm = ihm;
		
		this.setBorder(BorderFactory.createEmptyBorder(100, 20, 10, 10));
		this.add(new JLabel("Stats de "+ihm.getControleur().getUtilisateurCourant().getPseudo()));
		panelButton = new JPanel(new GridLayout(1,2));
		buttonJou = new JButton("3 derniers matchs");
		buttonJou.addActionListener(this);
		buttonGen = new JButton("Général");
		buttonGen.addActionListener(this);
		panelButton.add(buttonJou);
		panelButton.add(buttonGen);
		this.add(panelButton);
		labelStat = new JLabel("");
		this.add(labelStat);
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == buttonJou)
		{
			labelStat.setText(ihm.getControleur().getUtilisateurCourant().getStatsDixMatchs());
		}
		if(e.getSource() == buttonGen) {
			labelStat.setText(ihm.getControleur().getUtilisateurCourant().getStatsGeneral());
		}
		
	}
}
